import HeroData from "../data/HeroData";
import LoadManager from "../manager/LoadManager";

const {ccclass, property} = cc._decorator;

@ccclass
export default class HeroBox extends cc.Component {

    @property(cc.Sprite)
    img_avatar:cc.Sprite =null;

    @property(cc.Sprite)
    img_quality:cc.Sprite =null;

    private _heroData:HeroData
    
    public set heroData(v : HeroData) {
        this._heroData = v;
        this.img_quality.spriteFrame = LoadManager.instance.getImgResListByUrl("image/common/item_lv"+this._heroData.quality+"_bg");
        let id:string = this._heroData.avatarId
        let len:number = 4-id.length;
        for (let index = 0; index < len; index++) {
            id = "0"+id;  
        }
        this.img_avatar.spriteFrame = LoadManager.instance.getImgResListByUrl("image/head/r_"+id);
    }
    
    public get heroData() : HeroData {
        return this._heroData
    }
    
    start () {

    }
}
